package apiday06.thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                Boo.doSome();
            }
        };

        Thread t2 = new Thread() {
            @Override
            public void run() {
                Boo.doSome();
            }
        };

        t1.start();
        t2.start();

    }
}

class Boo {
    //    public synchronized static void doSome(){
    public static void doSome() {
        synchronized (Boo.class) {
            Thread t = Thread.currentThread();
            System.out.println(t + "开始执行doSome方法");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(t + "doSome方法执行完毕");
        }
    }
}